package cn.zjutleo.village_server.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author : 张坤
 * @date : Created in 2021/8/16
 * @description: Swagger配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(createApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zjutleo.village_server.controller"))
                .build();
    }

    /**
     * 配置Swagger接口信息
     *
     * @return ApiInfo
     */
    private ApiInfo createApiInfo() {
        Contact contact = new Contact("Qin Zhenghan", "https://github.com/Qin10", "1079913845@qq.com");
        return new ApiInfo(
                "JavaEE课程设计--村事宝后端接口的Swagger接口文档",
                "JavaEE课程设计",
                "v1.0.0",
                "https://gitee.com/qin-zhenghan/digital_village.git",
                contact,
                "Apache 2.0",
                "http://www.apache.org/license/LICENSE-2.0",
                new ArrayList()
        );
    }
}
